let MyPromise = require('./myPromise.js')

function p1() {
    return new MyPromise(function (resolve, reject) {
        setTimeout(function () {
            resolve('p1')
        }, 2000)
    })
}

function p2() {
    return new MyPromise(function (resolve, reject) {
        // resolve('p2 resolve')
        reject('p2 reject')
    })
}

// MyPromise.all(['a', 'b', p1(), p2(), 'c'])
//     .then(function (result) {
//         console.log(result)
//     })

// MyPromise.resolve(100).then(value => console.log(value))
// MyPromise.resolve(p1()).then(value => console.log(value))

p2().finally(() => {
        console.log('finally')
        return p1()
    })
    .then(() => console.log(1))
// .then(value => {
//     console.log(value)
// }, reason => {
//     console.log(reason)
// })

// p2()
//     .then(value => console.log(value))
//     .catch(reason => console.log(reason))